package me.send.business.service.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import me.send.business.base.SendVariable;
import me.send.business.service.BaseService;
import me.send.business.service.mapper.AdvertMapper;
import me.send.business.service.pojo.Advert;
import me.send.framework.util.HelperUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdvertService extends BaseService {

	@Autowired
	private AdvertMapper advertMapper;

	// 首页的广告页
	public Map<String, Object> list(HttpServletRequest request,String cityname) {
		Map<String, Object> map = new HashMap<String, Object>();
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("cityname", cityname);
		params.put("currentDate", HelperUtil.getCurrentDate());
		// 设置返回对象
		List<Advert> list = advertMapper.list(params);
		// 设置广告下面所有图片的链接
//		for (Advert advert : list) {
//			advert.setPicpath(HelperCommon.getBasicAllPath(request, advert
//					.getPicpath()));
//		}
		map.put(SendVariable.COMMON_LIST, list);
		// 返回状态
		map.put(SendVariable.COMM_ERROR, error_1000());
		return map;
	}
	
	/**
	 * 
	 * @param devicenumber
	 * @param userId
	 * @param advertId
	 * @return
	 * @author maxmin
	 * @date 2015年10月30日下午1:28:02
	 */
	public int checkIsDiscounted(int userId,int advertId,String date){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("userId", userId);
		params.put("advertId", advertId);
		params.put("date", date);
		return advertMapper.checkIsDiscounted(params);
	}
}
